$(function(){
	$("#headpicsel").change(function(){
		var imgUrl = $(this).val();
		$("#headImg").attr("src", imgUrl);
	});
	
	$("#msgSubmit").click(function(){
		var title = $("#msgTitle").val();
		var name = $("#msgName").val();
		var head = $("#headpicsel").val();
		var email = $("#msgEmail").val();
		var qq = $("#msgQQ").val();
		var homepage = $("#msgHomepage").val();
		var content = $("#msgContent").val();
		var isshow = $("#msgIsshow").attr("checked") == true ? 0 : 1;
		$.ajax({
			type : 'post',
			dataType : 'json',
			url : "/message/save",
			data : {
				'title' : title,
				'username' : name,
				'content' : content,
				'qq' : qq,
				'email' : email,
				'homepage' : homepage,
				'isshow' : isshow,
				'head' : head
			},
			success : function (data) {
				alert(data.errormsg);
				window.location.reload();
			},
			error : function () {
				alert('网络超时，请稍候再试！');
			}
		});
	});
});